<?php
// +----------------------------------------------------------------------
// | 牛逼网 [快乐 开放 游戏]
// +----------------------------------------------------------------------
// | Copyright (c) 2016 http://www.nniubi.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: zhy <345933361@qq.com>
// +----------------------------------------------------------------------
namespace Home\Controller;

/**
 * 前台默认控制器
 * @author zhy <345933361@qq.com>
 */
class OrderindexController extends HomeController
{
    /**
     * 小程序首页列表
     * @author zhy <345933361@qq.com>
     */
    public function index()
    {
        $page=I("get.page");
        if($page >0){
            $page = ($page - 1) * 9;
        }else{
            $page=0;
        }
        $where['status']=1;
        $where['type']=2;
        $count      = M("admin_article")->where($where)->count();
        $article=M("admin_article")->where(array($where))->order("add_time")->limit($page,9)->field("id,title,img")->select();
        foreach($article as $key => $value){
            $article[$key]['img']=$_SERVER["SERVER_NAME"].D('Admin/Upload')->getCover($value['img']);
        }
        $page=ceil($count/9);
        $array['data']=$article;
        $array['page']=$page;
        echo json_encode($array);

    }
}
